home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Interactive Media Design Review 1999
/
Interactive Media Design Review 1999.iso
/
pc
/
Demos
/
Herois
/
Codigo.Cst
/
00020_Script_Texto Scroll por Sensibilidade
< prev
next >
Wrap
Text File
|
1999-03-19
|
6KB
|
203 lines
property spr, mem
property interessados
property velMax, velMin, puloMax
property linhaAtual, linhaMax
property numLinhas
property alturaLinha, linhasJanela
property ultimoScroll, lastOut
property areaSensivel
property ligado, modificouCursor
property numCursor
on getPropertyDescriptionList
set p_list = [ ¼
#alturaLinha: [ #comment: "Altura (em pixels) de cada linha (0 p/ nao alterar)", ¼
#format: #integer,¼
#default: 16 ],¼
#velMax: [ #comment: "Velocidade maxima(pix/s)", ¼
#format: #integer,¼
#default: 96 ],¼
#velMin: [ #comment: "Velocidade minima(pix/s)", ¼
#format: #integer,¼
#default: 16 ],¼
#puloMax: [ #comment: "Maior pulo do scroll (em pixels)", ¼
#format: #integer,¼
#default: 16 ],¼
#interessados: [ #comment: "Sprites que se interessam pelo scroll:", ¼
#format: #list, ¼
#default: [] ],¼
#areaSensivel: [ #comment: "Area sensivel (em pixels)", ¼
#format: #integer,¼
#default: 48 ]¼
]
return p_list
end
on beginSprite me
set spr = the spriteNum of me
set mem = the member of sprite spr
set linhaAtual = 0
set numLinhas = the lineCount of member mem
if alturaLinha = 0 then
set alturaLinha = lineheight(mem, 1)
else
set the lineHeight of member mem to alturaLinha
end if
set linhasJanela = the height of sprite spr
set linhaMax = numLinhas
set linhaMax = numLinhas * alturaLinha - linhasJanela / 2
if linhaMax < 0 then set linhaMax = 0
set the scrollTop of member mem to 0
set ultimoScroll = the timer
set lastOut = true
-- set the visibility of sprite spr to false
-- set ligado = false
set modificouCursor = false
set numCursor = 1
end
on cleanSprite me
set the visibility of sprite (the spriteNum of me) to true
end
on idleSprite me
global gMustUpdate
-- if not ligado then
-- set the visibility of sprite spr to true
-- set ligado = true
-- set gMustUpdate = true
-- end if
if not the visible of sprite spr then return
-- Verifica se mouse passa por cima do texto
global gCritico
if not rollOver(spr) or gCritico > 0 then
set lastOut = true
if modificouCursor then
cursor -1
set modificouCursor = false
end if
return
end if
global gCritico, gMustUpdate
set y = the mouseV
-- Calcula velocidade conforme posicao do mouse
set v = 0
set y = y - the locV of sprite spr
if (y < areaSensivel) then
set v = -( (areaSensivel - y) * (velMax - velMin) / areaSensivel + velMin )
else
set y = (the height of sprite spr) - y
if (y < areaSensivel) then
set v = (areaSensivel - y) * (velMax - velMin) / areaSensivel + velMin
end if
end if
if v = 0 then
if not lastOut then set lastOut = true
if modificouCursor then
cursor -1
set modificouCursor = false
end if
return
end if
-- Calcula delta de linhas
if lastOut then
set lastOut = false
set ultimoScroll = the timer
return
end if
set dl = (the timer - ultimoScroll) * v / 60
if dl > 0 and linhaAtual = linhaMax then set dl = 0
else if dl < 0 and linhaAtual = 0 then set dl = 0
if dl = 0 then
if modificouCursor then
cursor -1
set modificouCursor = false
end if
return
end if
if dl > 0 then
cursor [the number of member ("CursorBaixo" & numCursor),¼
the number of member "CursorMask"]
set numCursor = 3 - numCursor
set modificouCursor = true
if dl > puloMax then
set dl = puloMax
end if
else
cursor [the number of member ("CursorCima" & numCursor),¼
the number of member "CursorMask"]
set numCursor = 3 - numCursor
set modificouCursor = true
if dl < - puloMax then
set dl = - puloMax
end if
end if
set ultimoScroll = the timer
-- Calcula nova linha
set l = linhaAtual + dl
if l < 0 then set l = 0
else if l > linhaMax then
set dl = dl + linhaMax
set l = linhaMax
end if
if l <> linhaAtual then
set the scrollTop of member mem to l
set gMustUpdate = true
repeat with i = 1 to count(interessados)
sendSprite(getAt(interessados,i), #scrollLinha, l - linhaAtual)
end repeat
set linhaAtual = l
end if
end
on mouseUp me
set y = the mouseV
set dl = 0
-- Calcula velocidade conforme posicao do mouse
set y = y - the locV of sprite spr
if (y < areaSensivel and linhaAtual > 0) then
puppetSound 2, "Warp1"
-- Scroll page down
set dl = - linhasJanela
-- termina if logo acima
else
set y = (the height of sprite spr) - y
if (y < areaSensivel and linhaAtual < linhaMax) then
puppetSound 2, "Warp2"
-- Scroll page up
set dl = + linhasJanela
end if
end if
if dl = 0 then return
-- Calcula nova linha
set l = linhaAtual + dl
if l < 0 then set l = 0
else if l > linhaMax then
set l = linhaMax
end if
if l <> linhaAtual then
set the scrollTop of member mem to l
repeat with i = 1 to count(interessados)
sendSprite(getAt(interessados,i), #scrollLinha, l - linhaAtual)
end repeat
set linhaAtual = l
end if
updateStage
stopEvent
end